package model;

import connection.DbConnection;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;
import bean.Message;
import bean.User_Msg;

public class InternalMail {
	
	public static boolean publicMessage (String sender, String [] pollList, String message) {
		 
		Connection conn = new DbConnection().getConn();
		
		// Loop through polls
		for (int i = 0; i < pollList.length; i++) {
			
			// Get poll id
			// Get users [] from db with pollId
			String [] users;
			privateMessage (sender, users, message);
			
		}
		
		return true;
	}
	
	public static boolean privateMessage (String sender, String [] userList, String message) {
		
		Connection conn2 = new DbConnection().getConn();
		
		// Insert message into db (sender, message)
		// Select * msgs where max create_time, save to new variable
		int MessageId = 0;
		
		// Loop through users, adding to Msg_user table
		for (int i = 0; i < userList.length; i++) {
			
			// Insert into database Msg_user table
			
		}
		
		return true;
	}
	
}
